# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: zlowly <zlowly@gmail.com>

pkgname=smartdns
pkgver=43
pkgrel=1
pkgdesc="A local DNS server to obtain the fastest website IP for the best Internet experience"
arch=('loong64' 'x86_64')
license=('GPL')
url="https://github.com/pymumu/smartdns"
backup=("etc/smartdns/smartdns.conf")
depends=('gcc-libs' 'openssl')
makedepends=('systemd')  # systemd.pc
checkdepends=('gtest' 'bind')
source=("$pkgname-$pkgver.tar.gz::https://github.com/pymumu/smartdns/archive/Release$pkgver.tar.gz")
sha512sums=('ab4ce7ac5fe05173a660f8dce61e7cc0ec8375ff7d64d08e854f73e5cfd78fec702220f076b75efe9518334a384b9689898d5c2856cc506d294b5325733bb9c6')

prepare() {
  # Unfortunately upstream does not provide a way to reuse .o files
  cp -a smartdns-Release$pkgver smartdns-Release$pkgver-test
}

build() {
  cd smartdns-Release$pkgver
  make RUNSTATEDIR=/run SBINDIR=/usr/bin
}

check() {
  cd smartdns-Release$pkgver-test
  make -C test test
}

package() {
  cd smartdns-Release$pkgver
  make RUNSTATEDIR=/run SBINDIR=/usr/bin DESTDIR="$pkgdir" install

  rm -r "$pkgdir"/etc/init.d
}
